package com.zksoo.drools.EnvironmentalPollution;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;
import org.kie.api.runtime.KieSession;

import com.zksoo.drools.model.EnvironmentalPollution;
import com.zksoo.drools.model.HeavyMetal;
import com.zksoo.drools.BaseTest;

public class EPTest extends BaseTest {

    @Test
    public void test() {
        KieSession kieSession = getKieSession("EnvironmentalPollution");

        EnvironmentalPollution p1 = new EnvironmentalPollution();
        p1.setConservationdistrict(true);
        p1.setRadioactivity_athogen_poison(true);

        EnvironmentalPollution p2 = new EnvironmentalPollution();
        p2.setHazardous(true);
        p2.setAmount(2);
        
        EnvironmentalPollution p3 = new EnvironmentalPollution();
        p3.setHazardous(true);
        p3.setAmount(5);
        
        EnvironmentalPollution p4 = new EnvironmentalPollution();
        p4.setEvaderegulation(true);
        p4.setRadioactivity_athogen_poison(true);
        
        EnvironmentalPollution p5 = new EnvironmentalPollution();
        
        List<HeavyMetal> heavyMetals = new ArrayList<HeavyMetal>();
        
        HeavyMetal hm1 = new HeavyMetal();
        hm1.setName("铅");
        hm1.setConcentration(2);
        hm1.setEmissionstandard(1.0f);
        
        HeavyMetal hm2 = new HeavyMetal();
        hm2.setName("镍");
        hm2.setConcentration(12);
        hm2.setEmissionstandard(1.0f);
        
        heavyMetals.add(hm1);
        heavyMetals.add(hm2);
        
        p5.setHeavyMetals(heavyMetals);
        
        kieSession.insert(p1);
        kieSession.insert(p2);
        kieSession.insert(p3);
        kieSession.insert(p4);
        kieSession.insert(p5);
        
        kieSession.insert(hm1);
        kieSession.insert(hm2);

        int count = kieSession.fireAllRules();
        kieSession.dispose();

        System.out.println("Fire " + count + " rule(s)!");

        System.out.println("The result of p1 is " + p1.getResult());
        System.out.println("The result of p2 is " + p2.getResult());
        System.out.println("The result of p3 is " + p3.getResult());
        System.out.println("The result of p4 is " + p4.getResult());
        System.out.println("The result of p5 is " + p5.getResult());

    }

}
